import React, { useState } from 'react';
import './addvip.scss'
import { Button,notification,Table,Tag,Drawer,Form,Input,Select,Tree } from 'antd'
import type { RadioChangeEvent } from 'antd';
import { Radio } from 'antd';
import * as service from '../../../../api/tzp'
import {useNavigate } from 'react-router-dom'
function Addvip(props:any) {
    var [form] = Form.useForm()
    let route = useNavigate()
    var onFinish =  async (formvalues:any)=>{
        console.log("haha");
        
        var date = new Date()
        console.log( formvalues );
        console.log(value);
        var res = await service.add_user({name:formvalues.name,phone:formvalues.phone,age:formvalues.age,wx:formvalues.wx,occupation:formvalues.occupation,address:formvalues.address,sex:value,vip:'普通',flag:1,num:4,money:5000,Integral:500,time:date})
        console.log(res);
        route('/index/search')
    }
    const [value, setValue] = useState('男');

    const onChange = (e: RadioChangeEvent) => {
      console.log(e.target.value);
      setValue(e.target.value);
    };
    return (
        <div className='addvip'>
            <div className='addvip-title'>
                新增会员
            </div>
            <div className='addvip-list'>
                    <Form
                        // className='from-box'
                        form={form}
                        // labelCol={{ span: 4 }}
                        wrapperCol={{ span: 14 }}
                        layout="horizontal"
                        style={{ maxWidth: 600 }}
                        onFinish={onFinish}
                    >
                        <Form.Item 
                            label="用户姓名" 
                            name="name"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Form.Item 
                            label="联系方式" 
                            name="phone"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Radio.Group className='checked-box' onChange={onChange} value={value} >
                            <Radio value={'男'}>男</Radio>
                            <Radio value={'女'}>女</Radio>
                        </Radio.Group>
                        <Form.Item 
                        
                            label="用户年龄" 
                            name="age"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Form.Item 
                            label="用户微信" 
                            name="wx"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Form.Item 
                            label="用户职业" 
                            name="occupation"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Form.Item 
                            label="详细地址" 
                            name="address"
                            >
                            <Input placeholder='请输入'/>
                        </Form.Item>
                        <Form.Item  >
                            <Button htmlType="submit">新增</Button>
                        </Form.Item>
                    </Form>
                
            </div>
        </div>
    );
}

export default Addvip;